<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/hairring/Public/Admin/css/index.css"/>
	</head>

	<body>
		<a href="<?php echo U('Admin/add');?>">注册</a>

		<!-- 用户列表 -->
		<table>
			<thead>
				<tr>
					<th>ID</th>
					<th>昵称</th>
					<th>密码</th>
					<th>时间</th>
					<th>等级</th>
					<th>状态</th>
					<th>操作</th>
					<th>操作</th>
					<th>操作</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<?php if(is_array($data)): $i = 0; $__LIST__ = $data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$row): $mod = ($i % 2 );++$i;?><tr>
						<td><?php echo ($row[id]); ?></td>
						<td onclick="AjaxUserInfo(<?php echo ($row[id]); ?>)"><?php echo ($row[username]); ?></td>
						<td><?php echo ($row[password]); ?></td>
						<td><?php echo date("Y-m-d H:i:s", $row[time]);?></td>
						<td><?php echo ($row[grade]); ?></td>
						<?php if($row[status] == 1): ?><td>开启</td>
							<td>
								<a href="<?php echo U('User/status',array('id'=>$row['id'],'status'=>$row['status']));?>">禁用</a>
							</td>
							<?php else: ?>
							<td>禁用</td>
							<td>
								<a href="<?php echo U('User/status',array('id'=>$row['id'],'status'=>$row['status']));?>">开启</a>
							</td><?php endif; ?>
						<td>
							<a href="<?php echo U('User/reset',array('id'=>$row['id']));?>">重置</a>
						</td>
						<td>
							<a href="<?php echo U('User/edit',array('id'=>$row['id']));?>">修改</a>
						</td>
						<td>
							<a href="<?php echo U('User/delete',array('id'=>$row['id']));?>">删除</a>
						</td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</tbody>

		</table>

		<!-- 分页 -->
		<nav><?php echo ($page); ?></nav>

		<div class="userinfo"></div>

		<script src="/hairring/Public/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>

		<script type="text/javascript">
			function AjaxUserInfo(user_id) {
				$.post("<?php echo U('User/ajax_userinfo');?>", {
						user_id: user_id,
					},
					function(data, status) {
						if(data != 0) {
							$(".userinfo").html(data);
						} else {
							$(".userinfo").html("该用户资料丢失！");
						}
					});
			}
		</script>
	</body>

</html>